<?php

namespace app\api\model;

use think\Model;
use traits\model\SoftDelete;

class Trends extends Model
{
    use SoftDelete;

    const ONLINE = 'yes';

    protected $deleteTime = 'deletetime';
    protected $hidden = ['is_show', 'updatetime', 'deletetime', 'sort'];

    public function getLogoAttr($value)
    {
        return $value ? request()->domain().$value : '';
    }

    public function getCreateTimeAttr($value)
    {
        return $value ? date('Y-m-d', $value) : '';
    }

    public static function getTrends($length = 10)
    {
        return self::where('is_show', self::ONLINE)->order('sort desc')->paginate($length);
    }
}
